<?php
	include_once('misc.php');
	$rv = 0;
	if( isset($_POST['login']) &&
		isset($_POST['pass'])) {
		$rv = reg_user($_POST['login'], $_POST['pass']);
		if(!$rv) {
			session_start();
			$_SESSION['login'] = $_POST['login'];
			header('Location:index.php');
		}
	}
?>
<!DOCTYPE html> <!-- HTML 5.0 -->
<html>
	<head>
		<meta http-equiv="Content-Type" 
					content="text/html; charset=utf-8"/>
		<title>Книжная лавка | Регистрация</title>
		<link rel="stylesheet" type="text/css" href="style.css"/>
	</head>
	<body>
		<? if($rv) { ?>
			<div class="warning">
				<?=$rv?>
			</div>
		<? } ?>
		<form action="reg.php" method="POST">
			<table class="reg">
				<tr>
					<td>Имя:</td>
					<td><input type="textfield" name="login"/></td>
				</tr>
				<tr>
					<td>Пароль:</td>
					<td><input type="password" name="pass"/></td>
				</tr>
				<tr>
					<td colspan="2">
						<input type="submit" value="Зарег"/>
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>
				